/**
 * 窗口面板，用于弹出窗口的设置
 * @author mayonghua
 * @param config
 * @return
 */
var WindowPanel = function(config){
	this.toolBar = config.toolBar;
	this.width = config.width;
	this.height = config.height;
	this.html = config.html;
	this.id = config.id;
	this.pic = config.pic;
	this.title = config.title;
	this.init();
}
WindowPanel.prototype = {
	init : function(){
		var entity = this;
		entity.drawDiv();
		var o = $("body",window.opener);
	},
	drawDiv : function(){
		var entity = this;
		var windowDiv = '<div class="window-div" id="'+entity.id+'"></div>'
			$(windowDiv).appendTo($(document.body));
		var windowTitle = '<div class="head"><span class="title">'+entity.title+'</span><span class="close"></span></div>';
			$(windowTitle).appendTo($("#"+entity.id));
		var windowContent = '<div class="windowContent" id="windowContent"></div>';
			$(windowContent).appendTo($("#"+entity.id));
		//为关闭按钮添加事件
		$("#"+entity.id+" .close").click(function(){
			$("#"+entity.id).remove();
		});
		//设置宽度和高度
		$("#"+entity.id).height(entity.height);
		$("#"+entity.id).width(entity.width);
		//设置位置
		var left = ($(document.body).width())/2-entity.width/2;
		var top = ($(document.body).height())/2-entity.height/2;
		$("#"+entity.id).css({left:left+"px",top:top+"px"});
		//添加toolBar
		if(entity.toolBar){
		var windowToolBar = '<div class="toolBar" id="windowToolBar"></div>';
		$(windowToolBar).insertAfter($("#"+entity.id+" .head"));
		this.addToolBar();
		}
		//添加页面
		$("#"+entity.id+" .windowContent").html(entity.html);
	},
	addToolBar : function(){
			var tb = this.toolBar;
			tb.renderTo = "windowToolBar";
			tb.render();
	}
}